package com.gyt.manager.common.enums;

import org.apache.commons.lang3.time.DateFormatUtils;

import java.util.Date;
import java.util.Random;

/**
 * @author v_yantgao
 */
public enum ModelDisFuncEnum {
    rand("IidHash2", "com.os.util.hash.IidHash2"),
    hash("Random", "com.os.util.hash.IRandom"),
    abt("AbtTest", "com.os.util.hash.AbtTest");

    private String name;
    private String path;

    ModelDisFuncEnum(String name, String path) {
        this.name = name;
        this.path = path;
    }

    public String getName() {
        return name;
    }

    public String getPath() {
        return path;
    }

    /**
     * 根据path获取对应的name
     *
     * @param path
     * @return
     */
    public static String getName(String path) {
        for (ModelDisFuncEnum disFuncEnum : values()) {
            if (disFuncEnum.getPath().equals(path)) {
                return disFuncEnum.getName();
            }
        }
        return "";
    }

    /**
     * 根据name获取对应的path
     *
     * @param name
     * @return
     */
    public static String getPath(String name) {
        for (ModelDisFuncEnum disFuncEnum : values()) {
            if (disFuncEnum.getName().equals(name)) {
                return disFuncEnum.getPath();
            }
        }
        return "";
    }

    private final static Random random = new Random();

    public static void main(String[] args) {
        StringBuilder sb = new StringBuilder();
        String strTime = DateFormatUtils.format(new Date(), "yyyyMMddHHmmss");
        String planBusinessId = sb.append("plan").append(strTime).append(+random.nextInt(10000)).toString();
        System.out.println(planBusinessId);
    }
}
